package cvslogic.elements;

import util.AuxiliaryFunctions;
import util.Constants;

import com.pavelvlasov.uml.Element;
import com.pavelvlasov.uml.ModelElement;

public class CompareModelElement {

	// Falta accept, getConstraints, getRootPath,

	public boolean equalsAbsoluteName(ModelElement newME, ModelElement oldME) {
		return newME.getAbsoluteName().equals(oldME.getAbsoluteName());
	}

	public boolean equalsStereotype(ModelElement newME, ModelElement oldME) {
		return newME.getStereotype().equals(oldME.getStereotype());
	}

	public boolean equalsType(ModelElement newME, ModelElement oldME) {
		return newME.getType().equals(oldME.getType());
	}

	public boolean equalsVisibility(ModelElement newME, ModelElement oldME) {
		return newME.getVisibility().equals(oldME.getVisibility());
	}

	public String getStereotypes(ModelElement newME, ModelElement oldME) {
		String out = "Old: ";
		if (oldME.getOwner() != null) {
			out += oldME.getOwner().getName();
		}
		out += " - New: ";
		if (newME.getOwner() != null) {
			out += newME.getOwner().getName();
		}

		return out;
	}

	public String getTypes(ModelElement newME, ModelElement oldME) {
		return "Old: " + oldME.getType() + " - New: " + newME.getType();
	}

	public String getVisibilities(ModelElement newME, ModelElement oldME) {
		return "Old: " + oldME.getVisibility() + " - New: "
				+ newME.getVisibility();
	}

	public void compareProperties(ModelElement oldModelElement,
			ModelElement newModelElement) {
		AuxiliaryFunctions.print(Constants.STEREOTYPE,
				equalsStereotype((ModelElement) newModelElement,
						(ModelElement) oldModelElement), getStereotypes(
						(ModelElement) newModelElement,
						(ModelElement) oldModelElement));
		AuxiliaryFunctions.print(Constants.TYPE,
				equalsType((ModelElement) newModelElement,
						(ModelElement) oldModelElement), getTypes(
						(ModelElement) newModelElement,
						(ModelElement) oldModelElement));
		AuxiliaryFunctions.print(Constants.VISIBILITY,
				equalsVisibility((ModelElement) newModelElement,
						(ModelElement) oldModelElement), getVisibilities(
						(ModelElement) newModelElement,
						(ModelElement) oldModelElement));
	}

}
